From 32eca924c4b053599bcf8484754f3b4e5b85bb1d Mon Sep 17 00:00:00 2001 From: Christian Limpach Date: Thu, 10 May 2007 15:17:20 +0100 Subject: [PATCH] [qemu] Remove -vnclisten option since the same functionality is now available using the -vnc option. Signed-off-by: Christian Limpach --- tools/ioemu/vl.c | 36 ++++++++++-------------------------- tools/ioemu/vl.h | 4 +--- tools/ioemu/vnc.c | 15 ++++++++------- 3 files changed, 19 insertions(+), 36 deletions(-) diff --git a/tools/ioemu/vl.c b/tools/ioemu/vl.c index e71001262c..af9067eb51 100644 --- a/tools/ioemu/vl.c +++ b/tools/ioemu/vl.c @@ -133,7 +133,6 @@ static DisplayState display_state; int nographic; int vncviewer; int vncunused; -struct sockaddr_in vnclisten_addr; const char* keyboard_layout = NULL; int64_t ticks_per_sec; char *boot_device = NULL; @@ -3020,22 +3019,10 @@ fail: return -1; } -int parse_host(struct sockaddr_in *saddr, const char *buf) -{ - struct hostent *he; - - if ((he = gethostbyname(buf)) != NULL) { - saddr->sin_addr = *(struct in_addr *)he->h_addr; - } else { - if (!inet_aton(buf, &saddr->sin_addr)) - return -1; - } - return 0; -} - int parse_host_port(struct sockaddr_in *saddr, const char *str) { char buf[512]; + struct hostent *he; const char *p, *r; int port; @@ -3046,8 +3033,14 @@ int parse_host_port(struct sockaddr_in *saddr, const char *str) if (buf[0] == '\0') { saddr->sin_addr.s_addr = 0; } else { - if (parse_host(saddr, buf) == -1) - return -1; + if (isdigit(buf[0])) { + if (!inet_aton(buf, &saddr->sin_addr)) + return -1; + } else { + if ((he = gethostbyname(buf)) == NULL) + return - 1; + saddr->sin_addr = *(struct in_addr *)he->h_addr; + } } port = strtol(p, (char **)&r, 0); if (r == p) @@ -6333,7 +6326,6 @@ void help(void) "-vnc display start a VNC server on display\n" "-vncviewer start a vncviewer process for this domain\n" "-vncunused bind the VNC server to an unused port\n" - "-vnclisten bind the VNC server to this address\n" "-timeoffset time offset (in seconds) from local time\n" #ifndef _WIN32 "-daemonize daemonize QEMU after initializing\n" @@ -6435,7 +6427,6 @@ enum { QEMU_OPTION_acpi, QEMU_OPTION_vncviewer, QEMU_OPTION_vncunused, - QEMU_OPTION_vnclisten, }; typedef struct QEMUOption { @@ -6518,7 +6509,6 @@ const QEMUOption qemu_options[] = { { "vnc", HAS_ARG, QEMU_OPTION_vnc }, { "vncviewer", 0, QEMU_OPTION_vncviewer }, { "vncunused", 0, QEMU_OPTION_vncunused }, - { "vnclisten", HAS_ARG, QEMU_OPTION_vnclisten }, /* temporary options */ { "usb", 0, QEMU_OPTION_usb }, @@ -7086,8 +7076,6 @@ int main(int argc, char **argv) nb_nics = 0; /* default mac address of the first network interface */ - - memset(&vnclisten_addr.sin_addr, 0, sizeof(vnclisten_addr.sin_addr)); /* init debug */ sprintf(qemu_dm_logfilename, "/var/log/xen/qemu-dm.%ld.log", (long)getpid()); @@ -7492,9 +7480,6 @@ int main(int argc, char **argv) case QEMU_OPTION_vncunused: vncunused++; break; - case QEMU_OPTION_vnclisten: - parse_host(&vnclisten_addr, optarg); - break; } } } @@ -7794,8 +7779,7 @@ int main(int argc, char **argv) dumb_display_init(ds); } else if (vnc_display != NULL || vncunused != 0) { int vnc_display_port; - vnc_display_port = vnc_display_init(ds, vnc_display, vncunused, - &vnclisten_addr); + vnc_display_port = vnc_display_init(ds, vnc_display, vncunused); if (vncviewer) vnc_start_viewer(vnc_display_port); xenstore_write_vncport(vnc_display_port); diff --git a/tools/ioemu/vl.h b/tools/ioemu/vl.h index 4ca91e4dc7..1d8a383728 100644 --- a/tools/ioemu/vl.h +++ b/tools/ioemu/vl.h @@ -37,8 +37,6 @@ #include #include #include -#include -#include #include "xenctrl.h" #include "xs.h" #include @@ -956,7 +954,7 @@ void sdl_display_init(DisplayState *ds, int full_screen); void cocoa_display_init(DisplayState *ds, int full_screen); /* vnc.c */ -int vnc_display_init(DisplayState *ds, const char *display, int find_unused, struct sockaddr_in *iaddr); +int vnc_display_init(DisplayState *ds, const char *display, int find_unused); void do_info_vnc(void); int vnc_start_viewer(int port); diff --git a/tools/ioemu/vnc.c b/tools/ioemu/vnc.c index 83ea3a43fc..46f1682e63 100644 --- a/tools/ioemu/vnc.c +++ b/tools/ioemu/vnc.c @@ -1393,9 +1393,10 @@ static void vnc_listen_read(void *opaque) extern int parse_host_port(struct sockaddr_in *saddr, const char *str); -int vnc_display_init(DisplayState *ds, const char *arg, int find_unused, struct sockaddr_in *iaddr) +int vnc_display_init(DisplayState *ds, const char *arg, int find_unused) { struct sockaddr *addr; + struct sockaddr_in iaddr; #ifndef _WIN32 struct sockaddr_un uaddr; #endif @@ -1456,8 +1457,8 @@ int vnc_display_init(DisplayState *ds, const char *arg, int find_unused, struct } else #endif { - addr = (struct sockaddr *)iaddr; - addrlen = sizeof(*iaddr); + addr = (struct sockaddr *)&iaddr; + addrlen = sizeof(iaddr); vs->lsock = socket(PF_INET, SOCK_STREAM, 0); if (vs->lsock == -1) { @@ -1465,12 +1466,12 @@ int vnc_display_init(DisplayState *ds, const char *arg, int find_unused, struct exit(1); } - if (parse_host_port(iaddr, arg) < 0) { + if (parse_host_port(&iaddr, arg) < 0) { fprintf(stderr, "Could not parse VNC address\n"); exit(1); } - iaddr->sin_port = htons(ntohs(iaddr->sin_port) + 5900); + iaddr.sin_port = htons(ntohs(iaddr.sin_port) + 5900); reuse_addr = 1; ret = setsockopt(vs->lsock, SOL_SOCKET, SO_REUSEADDR, @@ -1483,7 +1484,7 @@ int vnc_display_init(DisplayState *ds, const char *arg, int find_unused, struct while (bind(vs->lsock, addr, addrlen) == -1) { if (find_unused && errno == EADDRINUSE) { - iaddr->sin_port = htons(ntohs(iaddr->sin_port) + 1); + iaddr.sin_port = htons(ntohs(iaddr.sin_port) + 1); continue; } fprintf(stderr, "bind() failed\n"); @@ -1500,7 +1501,7 @@ int vnc_display_init(DisplayState *ds, const char *arg, int find_unused, struct exit(1); } - return ntohs(iaddr->sin_port); + return ntohs(iaddr.sin_port); } int vnc_start_viewer(int port) -- 2.30.2